import { ProFormSelect } from "@ant-design/pro-form";
import { useAxiosGet, useAxiosWebPost } from "@sker/sdk";
import React, { useState } from "react";


export const TmapInput: React.FC<{ name?: string, value?: string, onChange: (val: any) => void }> = ({ value, onChange }) => {
    const { fetch: search } = useAxiosWebPost('imeepos/tmap/suggestion')
    return <ProFormSelect.SearchSelect
        showSearch
        mode={'single'}
        placeholder={value}
        onChange={(e, option)=> {
            onChange(option)
        }}
        debounceTime={500}
        request={async (params) => {
            const result = await search({ keyword: params.keyWords || value || '公司' })
            const list = (result.data || []).flat().map((it: any) => {
                it.label = it.address;
                it.value = it.id;
                return it;
            })
            return list;
        }} />
}